package com.ganbo.rabbitmq.basic.redirect;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;

@Configuration
public class DirectConfig {


    //交换机
    public final static String EXCHANGE_direct_direct = "ganbo.exchange.direct";

    //队列
    public final static String TOPIC_direct1 = "ganbo.topic.direct1";
    public final static String TOPIC_direct2 = "ganbo.topic.direct2";

    //声明交换机
    @Bean
    public DirectExchange exchange1() {
        return new DirectExchange(EXCHANGE_direct_direct, true, false, new HashMap<>());
    }


    //声明队列
    @Bean
    public Queue queuePay11() {
        return new Queue(DirectConfig.TOPIC_direct1, true);
    }

    @Bean
    public Queue queuePay22() {
        return new Queue(DirectConfig.TOPIC_direct2, true);
    }


    //绑定队列
    @Bean
    Binding bindingExchangeMessage11() {
        return BindingBuilder.bind(queuePay11()).to(exchange1()).with("aaa");
    }

    @Bean
    Binding bindingExchangeMessage22() {
        return BindingBuilder.bind(queuePay22()).to(exchange1()).with("aaa");
    }

}
